﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using WoChu.RfClient.Entity;

namespace WoChu.RfClient.Duty
{

    public class PickLocationRelationUIRule
    {
        private static PickLocationRelationUIRule _NewInstance = new PickLocationRelationUIRule();

        public static PickLocationRelationUIRule NewInstance
        {
            get
            {
                if (_NewInstance == null)
                {
                    _NewInstance = new PickLocationRelationUIRule();
                }

                return _NewInstance;
            }
        }

        public ResultModel<LocationGoodsInfo> ExistLoctionGoodsByLocationCode(string code)
        {
            try
            {

                var _result = WoChu.CF.BaseFrame.WebClient.WebGetHelper<IPickLocationRelation>.NewInstance.InvokeWebMethod<ResultModel<LocationGoodsInfo>>("ExistLoctionGoodsByLocationCode", new object[] { code });
                if (_result == null)
                    return new ResultModel<LocationGoodsInfo>().GetInstance();
                return _result;
            }
            catch (Exception ex)
            {
                WoChu.CF.BaseFrame.Util.MessageBoxEx.Show(ex);
                return new ResultModel<LocationGoodsInfo>().GetInstance();
            }
        }
        public ResultModel<LocationGoodsInfo> ExistLoctionGoodsByGoodsCode(string code)
        {
            try
            {

                var _result = WoChu.CF.BaseFrame.WebClient.WebGetHelper<IPickLocationRelation>.NewInstance.InvokeWebMethod<ResultModel<LocationGoodsInfo>>("ExistLoctionGoodsByGoodsCode", new object[] { code });
                if (_result == null)
                    return new ResultModel<LocationGoodsInfo>().GetInstance();
                return _result;
            }
            catch (Exception ex)
            {
                WoChu.CF.BaseFrame.Util.MessageBoxEx.Show(ex);
                return new ResultModel<LocationGoodsInfo>().GetInstance();
            }
        }

        public ResultModel<bool> DeleteLoctionGoodsRelation(int locationGoodsId)
        {
            try
            {
                var _result = WoChu.CF.BaseFrame.WebClient.WebGetHelper<IPickLocationRelation>.NewInstance.InvokeWebMethod<ResultModel<bool>>("DeleteLoctionGoodsRelation", new object[] { locationGoodsId });
                if (_result == null)
                    return new ResultModel<bool>().GetInstance();
                return _result;
            }
            catch (Exception ex)
            {
                WoChu.CF.BaseFrame.Util.MessageBoxEx.Show(ex);
                return new ResultModel<bool>().GetInstance();
            }
        }
        //分拣货位关联提交  
        public ResultModel<bool> SetLocationGoodsPick(string userID, List<LocationGoodsInfo> lstLocationGoods)
        {
            try
            {
                ResultModel<bool> _result = WoChu.CF.BaseFrame.WebClient.WebGetHelper<IPickLocationRelation>.NewInstance.InvokeWebMethod<List<LocationGoodsInfo>, ResultModel<bool>>("SetLocationGoodsPick", new object[] { userID }, lstLocationGoods);

                return _result;
            }
            catch (Exception ex)
            {
                WoChu.CF.BaseFrame.Util.MessageBoxEx.Show(ex);
            }
            return null;
        }
    }
}
